import de.ruedigermoeller.fastcast.service.fcdemon.FCDemon;
import de.ruedigermoeller.fastcast.service.fcdemon.FCStartScript;
import de.ruedigermoeller.fastcast.test.StructBench;

import java.lang.Exception;
import java.lang.Integer;
import java.util.List;

/**
 * fcon -j BigTest
 * can be changed without recompile. No Generics support (janino)
 */
public class SBench extends FCStartScript {

    @Override
    public void startCluster(String arg, List demons) {
        String args[] = arg.split(" ");
        try {
            int numSender = 1;
            int numReceiver = 1;
            String type = "1";
            try {
                numSender = Integer.parseInt(args[0]);
            } catch (Exception e) {

            }
            try {
                numReceiver = Integer.parseInt(args[1]);
            } catch (Exception e) {

            }
            if ( args.length >= 3 )
                type = args[2];

            String opts = "-Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:-UseAdaptiveSizePolicy -XX:SurvivorRatio=8 -XX:NewRatio=2 ";

            for ( int i = 0; i < numSender; i++) {
                System.out.println("Starting Sender node "+StructBench.class.getName()+"-"+i);
                FCDemon.ProcessEntry en = startNode(opts,StructBench.class, type);
                if ( en == null ) {
                    System.out.println("   failed");
                }
            }
            for ( int i = 0; i < numReceiver; i++) {
                System.out.println("Starting node "+StructBench.class.getName()+"-"+i);
                FCDemon.ProcessEntry en = startNode(opts,StructBench.class, "");
                if ( en == null ) {
                    System.out.println("   failed");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
